enyo.kind({
	name: "webFTP",
	kind: enyo.VFlexBox,
	components: [
	    {kind: "Scrim", layoutKind: "VFlexLayout", align: "center", 
			pack: "center", components: [
			    {kind: "SpinnerLarge"}
		]},
	    {name: "slidingPane", kind: "SlidingPane", flex: 1, components: [
			{name: "hosts", width: "320px", kind:"webFTP.HostList",
				onConfig: "hostConfig"},
			{name: "main", kind:"webFTP.Transfer"}
		]},
		{name: "config", lazy: false, kind:"webFTP.Config", 
			onClose: "configSaved"
		},
		{name: "popup", kind: "webFTP.popUp", onOk: "popupOk", 
			onCancel: "popupCancel"}//, onClose: "popupCancel"}
	],
	create: function() {
		this.inherited(arguments);
		//this.$.config.open();
		var recToConfig = [];
	},
	hostConfig: function(inSender, inHost) {
		var s = enyo.fetchControlSize(this);
		
		recToConfig = this.$.hosts.getHostListItem(inHost);

    	this.$.config.configHost(recToConfig);
		
    	this.showToaster();
	},
    configSaved: function(inSender, inHost) {
    	this.$.scrim.show();
	    this.$.popup.openAtCenter();
    },
    showToaster: function() {
		this.$.config.open();
	},
    popupOk: function() {
    	this.$.popup.close();
    	this.$.scrim.hide();
    	
    	recToConfig = {
		    			"rowID"	:	this.$.config.$.itemID.getValue(),
		    			"title"	:	this.$.config.$.title.getValue(),
		    			"host"	:	this.$.config.$.name.getValue(),
		    			"port"	:	this.$.config.$.port.getValue(),
		    			"type"	:	this.$.config.$.type.getValue(),
		    			"user"	:	this.$.config.$.uid.getValue(),
		    			"pass"	:	this.$.config.$.pass.getValue(),
		    			"locDir":	this.$.config.$.locdir.getValue(),
		    			"remDir":	this.$.config.$.remdir.getValue()
		    		  }
    	
    	this.$.hosts.editHost(recToConfig);
    },
	popupCancel: function() {
		this.$.popup.close();
		this.$.scrim.hide();
	}
});